package com.atguigu.ssyx.order.api;

import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.model.order.OrderInfo;
import com.atguigu.ssyx.order.service.IOrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "Order管理", tags = "Order管理")
@RestController
@RequestMapping(value = "/api/order")
@RequiredArgsConstructor
public class OrderApiController {

    private final IOrderInfoService orderInfoService;

    @ApiOperation("获取订单详情")
    @GetMapping("auth/getOrderInfoById/{orderId}")
    public Result getOrderInfoById(@PathVariable("orderId") Long orderId) {
        return Result.ok(orderInfoService.getOrderInfoById(orderId));
    }

    @ApiOperation("根据orderNo查询订单信息")
    @GetMapping("/inner/order/getOrderInfoByOrderNo/{orderNo}")
    OrderInfo getOrderInfoByOrderNo(@PathVariable String orderNo) {
        return orderInfoService.getOrderInfoByOrderNo(orderNo);
    }
}